package com.test.spring4;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * Hello world!
 *
 */
public class App 
{
    public static void main( String[] args )
    {
    	//AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(MyConfige.class,User.class,UserDao.class,UserService.class,UserController.class);
    	AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext("com.test.spring4");
    	System.out.println(context.getBean(MyBean.class));
    	System.out.println(context.getBean("myBean"));
    	System.out.println(context.getBean(Jeep.class));//jeep对象
    	System.out.println(context.getBean("createRunableFactoryBean"));//jeep对象
    	System.out.println(context.getBean("&createRunableFactoryBean"));//RunableFactoryBean对象
    	System.out.println(context.getBean(RunableFactoryBean.class));//RunableFactoryBean对象
    	System.out.println(context.getBean(Car.class));//Car对象
    	System.out.println(context.getBean(Cat.class));
    	System.out.println(context.getBean(Dog.class));
    	System.out.println(context.getBean(Annimal.class));
    	System.out.println(context.getBean(User.class));
    	System.out.println(context.getBeansOfType(User.class));//map对象
    	//System.out.println(context.getBean("User"));//@Component注解的不能使用这种方法
    	System.out.println(context.getBean(UserDao.class));
    	System.out.println(context.getBean(UserService.class));
    	System.out.println(context.getBean(UserController.class));
    	
    	User user = context.getBean("myUser",User.class);
    	user.show();
    	
    	context.close();
    } 
}
